package net.wofly.sale.exchange.validator;

import org.springframework.util.StringUtils;

import net.wofly.sale.exchange.domain.ExchangeType;

public class ExchangeTypeValidator {
	
	/**
     * 换行符
     */
    private static String lineSeparator = System.getProperty("line.separator");

    public static String validateAddExchangeTypeInParams(ExchangeType exchangeType) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(exchangeType.getExchangeTypeName())) {
            stringBuffer.append("兑换类型名称不能为空").append(lineSeparator);
        }
        if (StringUtils.isEmpty(exchangeType.getValue())) {
            stringBuffer.append("面值不能为空").append(lineSeparator);
        }
        
        return stringBuffer.toString();
    }
    
    public static String validateUpdateExchangeTypeInParams(ExchangeType exchangeType) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(exchangeType.getExchangeTypeID())) {
            stringBuffer.append("兑换类型ID不能为空").append(lineSeparator);
        }
        
        if (StringUtils.isEmpty(exchangeType.getExchangeTypeName())) {
            stringBuffer.append("兑换类型名称不能为空").append(lineSeparator);
        }
        if (StringUtils.isEmpty(exchangeType.getValue())) {
            stringBuffer.append("面值不能为空").append(lineSeparator);
        }
        
        return stringBuffer.toString();
    }
    
    public static String validateExchangeTypeID(String exchangeTypeID) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(exchangeTypeID)) {
            stringBuffer.append("兑换类型ID不能为空").append(lineSeparator);
        }
        
        return stringBuffer.toString();
    }

}
